use std::ops::{Deref, DerefMut};

use serde::Deserialize;

use crate::error::AppErr;

#[repr(transparent)]
pub struct Cbor<T>(pub T);

pub struct Verify;
pub struct Void;

pub struct Download {
    pub body: Box<[u8]>,
    pub name: String,
}

pub type CborRet<T> = Result<Cbor<T>, AppErr>;

pub fn cbor_ok<T>(value: T) -> Result<Cbor<T>, AppErr> {
    Ok(Cbor(value))
}

impl<T> Deref for Cbor<T> {
    type Target = T;
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl<T> DerefMut for Cbor<T> {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

#[derive(Debug, Deserialize)]
pub struct IdReq {
    pub id: i64,
}

#[derive(Debug, Deserialize)]
pub struct TypeIdReq {
    pub type_id: i64,
}

